
#Configure the HuaweiCloud Provider
terraform {
  required_providers {
    huaweicloud = {
      source = "local-registry/huaweicloud/huaweicloud"
      version = "= 1.34.1"
    }
  }
}

provider "huaweicloud" {
  region     ="cn-north-4"
  access_key = ""
  secret_key = ""
}


resource "huaweicloud_cdn_domain" "domain" {
  name = var.accelerate_domain
  type = "wholeSite"
  service_area = var.service_area

sources {
    origin = var.originServer_address
    origin_type = var.originServer_type
    active      = 1
  }
}

resource "huaweicloud_dns_zone" "zone" {
  name        = var.publicZone_domain
  ttl         = 3000
  zone_type   = "public"
}

resource "huaweicloud_dns_recordset" "rs_example_com" {
  zone_id     = huaweicloud_dns_zone.zone.id
  name        = var.accelerate_domain
  description = "record set"
  ttl         = 3000
  type        = "CNAME"
  records     = [huaweicloud_cdn_domain.domain.cname]
}
